 
 
 
 
 
    use RFS_master_data, clear

 
 	expand 2 , gen(typeG) 
   replace typeG = typeG + 1
  
 
 gen 	 D4_MARKET = 4 if activeZ == 1 & typeG  == 2
 replace D4_MARKET = 3 if activeZ == 1 & typeG  == 1
 replace D4_MARKET = 2 if activeZ == 0 & typeG  == 2
 replace D4_MARKET = 1 if activeZ == 0 & typeG  == 1
 
  
    gen aux  =  rnormal(0,2)   						   // randomise costs for the nre rows / "corporates"
	 replace N_aver = N_aver + aux 	if typeG == 2	   // random costs
  
  global varIN " D4_MARKET"
 global vars3 "    N_aver    "

			 
	 local gg = 1
  	 mat UNews_Sop = J(4,1,1)
	 mat UNews_Uns = J(4,1,1)
  foreach jj of global varIN {
   foreach j of global vars3 {
  di "`j'_`ii'"
  cap drop yy xx*
 gen yy = `j'
 gen xx = size
 gen xxActive = activeZ 
 qui winsor2 xx , replace cuts(1 99)
  qui winsor2 yy , replace cuts(1 99)

 cap estimates drop ggg*
 qui {
 	reghdfe yy  c.xx#i.`jj' , absorb(st0_date#instrumentid#xxActive   call#typeG coun#typeG#xxActive      )    cluster(call   st0_date)
  estimates store ggg1
    test 1.`jj'#c.xx = 2.`jj'#c.xx
    local gg2 = r(p)
    mat UNews_Uns[1,`gg'] = `gg2'
    test 3.`jj'#c.xx = 4.`jj'#c.xx
    local gg3 = r(p)
    mat UNews_Sop[1,`gg'] = `gg3'
	
 	reghdfe yy  c.xx#i.`jj'  , absorb(st0_date#instrumentid#xxActive  mm#call   st0_date#coun#xxActive call#typeG coun#typeG#xxActive  )    cluster(call   st0_date)
  estimates store ggg2
    test 1.`jj'#c.xx = 2.`jj'#c.xx
    local gg2 = r(p)
    mat UNews_Uns[2,`gg'] = `gg2'
    test 3.`jj'#c.xx = 4.`jj'#c.xx
    local gg3 = r(p)
    mat UNews_Sop[2,`gg'] = `gg3'
	
 	reghdfe yy  c.xx#i.`jj'  , absorb(st0_date#instrumentid#xxActive  mm#call st0_date#coun#xxActive call#coun call#typeG coun#typeG#xxActive  )    cluster(call   st0_date)
  estimates store ggg3
     test 1.`jj'#c.xx = 2.`jj'#c.xx
    local gg2 = r(p)
    mat UNews_Uns[3,`gg'] = `gg2'
    test 3.`jj'#c.xx = 4.`jj'#c.xx
    local gg3 = r(p)
    mat UNews_Sop[3,`gg'] = `gg3'
	
 	reghdfe yy  c.xx#i.`jj'   , absorb(st0_date#instrumentid#xxActive  mm#call st0_date#coun#xxActive call#coun#typeG)    cluster(call   st0_date)
  estimates store ggg4
     test 1.`jj'#c.xx = 2.`jj'#c.xx
    local gg2 = r(p)
    mat UNews_Uns[4,`gg'] = `gg2'
    test 3.`jj'#c.xx = 4.`jj'#c.xx
    local gg3 = r(p)
    mat UNews_Sop[4,`gg'] = `gg3'	

  
	}
   esttab ggg*  /*  using size_linear_`j'_DS2.tex using size_linear_`j'.tex  */   ///
 , star("*" 0.1 "**" 0.05 "***" 0.01) b(%10.3f) t(%10.2f) scalars(N r2) sfmt(%10.3f)   replace
 
	 esttab ggg* using "RFScrossmarket.tex"   ///
	, star("*" 0.1 "**" 0.05 "***" 0.01) b(%10.3f) t(%10.2f) scalars(N r2) sfmt(%10.3f)   replace
 
 local gg = `gg' + 1

  } 
  }
  
  * SHOW THE P-values : 
		mat list UNews_Uns
		mat list UNews_Sop
	